class_name Game
extends Node

var total_pieces_container : Array[Piece] = []


func add_piece_to_total(piece : Piece):
	#print("现在有" + str(total_pieces_container.size())+"块俄罗斯方块")
	total_pieces_container.append(piece)

func clear_line(piece_container:Array[Piece]):
	#print("信号触发了!piece_container里有： " + str(piece_container.size()))
	var to_remove = []
	
	for need_clear_piece in piece_container :
		if total_pieces_container.find(need_clear_piece) != -1:
			to_remove.append(need_clear_piece)
		else:
			print("无效的对象，无法删除")
			
	for piece in to_remove:
		piece_container.erase(piece)
		total_pieces_container.erase(piece)
		piece.queue_free()
		
	#move_down_all_pieces()
		
func move_down_all_pieces():
	for all_pieces in total_pieces_container:
		
		all_pieces.position = all_pieces.position + Vector2.DOWN * all_pieces.get_size()
